package com.hnu.web;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.hnu.model.Bookmark;
import com.hnu.model.User;

public class NologinIndexBean extends BaseAction {
	private static final long serialVersionUID = 1471893260082927686L;
	private String query;
	private List<Bookmark> bookmarkList;
	
	public String initAction()
	{
		User user = (User) this.session.get("user");
		if(user != null)
		{
			return "logined";
		}
		bookmarkList = this.servLocator.getBookmarkServ().getTopNBookmark(10);
		return "success";
	}
	
	public String search()
	{
		User user = (User) this.session.get("user");
		if(user != null)
		{
			return "logined";
		}
		String indexPath = ServletActionContext.getRequest().getRealPath("/") + "indexPath";
		bookmarkList = this.servLocator.getBookmarkServ().getSearchBookmark(query, 20, indexPath);
		return "success";
	}

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public List<Bookmark> getBookmarkList() {
		return bookmarkList;
	}

	public void setBookmarkList(List<Bookmark> bookmarkList) {
		this.bookmarkList = bookmarkList;
	}

}
